/* 
 * File:   ServerSocketImpl.h
 * Author: ariel
 *
 * Created on December 4, 2009, 2:10 AM
 */

#ifndef _SERVERSOCKETIMPL_H
#define	_SERVERSOCKETIMPL_H
#include "ServerSocket.h"
#include "../engine/SearchEngine.h"
#include "thread/Thread.h"
#include "../engine/EngineFacadeThread.h"

class Runnable;

class ServerSocketImpl : public Runnable {
public:
    friend void* run(void*);
    ServerSocketImpl(int port=8999,SearchEngine*engine=NULL):server(port){
        this->engine=engine;
        this->running=true;
    }
    void startListen();
    void run();
    void setRunning(bool state){
        this->running=state;
    }
    ServerSocketImpl(const ServerSocketImpl& orig);
    virtual ~ServerSocketImpl();
private:
    bool running;
    static bool parche;
    ServerSocket server;
    pthread_t thread;
    SearchEngine* engine;
};

#include "thread/Runnable.h"

#endif	/* _SERVERSOCKETIMPL_H */

